package com.njupt;

import java.util.ArrayList;

/**
 * @Author: wujiaming
 * @CreateTime: 2025/5/7 15:12
 * @Description:
 * @Version: 1.0
 */




public class Test<K,V> {





    private static final int DEFAULT_CAPACITY = 10;
    private static final float LOAD_FACTOR  = 0.75f;


    private Node<K,V>[] table;
    private int size;

    private static class Node<K,V>{
        final K key;
        V value;
        Node<K,V> next;

        Node(K key, V value, Node<K,V> next){
            this.key = key;
            this.value = value;
            this.next = next;
        }
    }

    public Test(){
        table = (Node<K,V>[]) new Node[DEFAULT_CAPACITY];
        size = 0;
    }

    private int hash(K key){
        if(key == null) return 0;
        int h = key.hashCode();
        return (h ^ (h >>> 16) & table.length -1);
    }

    public void put(K key ,V value){
        if(key == null){
            pubtForNullKey(value);
            return;
        }
        int index = hash(key);
        Node<K,V> node = table[index];

        while(node != null){
            if(key.equals(node.key)){
                node.value = value;
                return;
            }
            node = node.next;
        }
    }



    public void pubtForNullKey(V value){
        Node<K,V> node = table[0];
        while(node != null){
            if(node.key == null){
                node.value = value;
                return;
            }
            node = node.next;
        }
        table[0] = new Node<>(null,value,table[0]);


    }



    public static void main(String[] args) {


    }
}
